package com.cesgroup.zw.spring.boot.library.echarts.barAndScatter.complex;

import com.cesgroup.zw.spring.boot.echarts.build.EChartsOption;
import com.cesgroup.zw.spring.boot.echarts.component.Grid;
import com.cesgroup.zw.spring.boot.echarts.component.TextStyle;
import com.cesgroup.zw.spring.boot.echarts.component.axis.XAxis;
import com.cesgroup.zw.spring.boot.echarts.component.axis.YAxis;
import com.cesgroup.zw.spring.boot.echarts.model.axis.AxisLabel;
import com.cesgroup.zw.spring.boot.echarts.model.axis.AxisLine;
import com.cesgroup.zw.spring.boot.echarts.model.style.LineStyle;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * <p>柱状图和圆实现top榜单</p>
 * @author ytj
 * @date 2019/7/5 13:44
 */
@SuppressWarnings("serial")
public class ComplexBarAndScatterOption extends EChartsOption{
    public ComplexBarAndScatterOption(ComplexBarAndScatterParam param){
        this.setBackgroundColor("#0e2147");
        this.setGrid(new Grid(){{
            this.setLeft("25%");
            this.setTop("12%");
            this.setRight("25%");
            this.setBottom("8%");
            this.setContainerLabel(true);
        }});
        this.setXAxis(new XAxis(){{
            this.setShow(false);
        }});
        this.setYAxis(new YAxis[]{
                new YAxis(){{
                    this.setOffset(27);
                    this.setAxisLabel(new AxisLabel(){{
                        this.setColor("#ffffff");
                        this.setFontSize(16);
                    }});
                    this.setData(arrayToList((Object[]) param.getDataset().get("name")));
                }},
                new YAxis(){{
                    this.setAxisLabel(new AxisLabel(){{
                        this.setColor("#ffffff");
                        this.setFontSize(0);
                    }});
                }},
                new YAxis(){{
                    this.setName("工作地TOP 10");
                    this.setNameGap(30);
                    this.setNameTextStyle(new TextStyle(){{
                        this.setColor("#ffffff");
                        this.setFontSize(30);
                    }});
                    this.setAxisLine(new AxisLine(){{
                        this.setLineStyle(new LineStyle(){{
                            this.setColor("rgba(0,0,0,0)");
                        }});
                    }});
                }},
        });
    }
    public List<Object> arrayToList(Object[] array){
        List<Object> list=new ArrayList<>();
        Arrays.stream(array).forEach(e->list.add(e));
        return list;
    }
}
